const { i18n } = require("./next-i18next.config");

// 环境变量
const BUILD_ENV = process.env.BUILD_ENV || "";

// 获取站点前缀
const getSitePrefix = () => {
  switch (BUILD_ENV) {
    case "test":
      return "test-"; // test 环境
    case "perf":
      return "perf-"; // qris 环境
    case "sit":
      return "sit-"; // sit 环境
    case "pre":
      return "pre-"; // pre 压测环境
    default:
      return ""; // prod 生产环境
  }
};

// 站点前缀
const sitePrefix = getSitePrefix();

/** @type {import('next').NextConfig} */
const nextConfig = {
  reactStrictMode: true,
  async rewrites() {
    return [
      {
        source: "/pro-api",
        destination: `https://${sitePrefix}mobile-api.bankneo.co.id`,
      },
    ];
  },
  env: {
    BUILD_ENV,
  },
  i18n,
};

module.exports = nextConfig;
